#include <REGX52.H>
#include "LCD1602.h"
#include "MatrixKey.h"
#include "Delay.h"

unsigned int KeyNum;
unsigned int Answer;

void main()
{
	LCD_Init();
	LCD_ShowString(1,1,"Answer:");
	while(1)
	{
		
		KeyNum=Matrixkey();
		if(KeyNum)
		{
			if(Answer<1000)
			{
				if(KeyNum<=10)
				{
					Answer*=10;
					Answer+=KeyNum;
				}
			}
		}
		LCD_ShowNum(1,8,Answer,4);
		
		if(KeyNum==11)
		{
			if(Answer==1314)
			{	
				LCD_ShowString(2,1,"Right");
				Answer=0;
				LCD_ShowString(1,1,"Again:");
				LCD_ShowString(1,7,"Right ");
				LCD_ShowNum(1,7,Answer,3);
				
			}
			else if(Answer<1314)
			{	
				LCD_ShowString(2,1,"Small");
				LCD_ShowString(1,1,"Again:");
				Answer=0;
				LCD_ShowString(1,7,"Right ");
				LCD_ShowNum(1,7,Answer,3);
			}
			else if(Answer>1314)
			{	
				LCD_ShowString(2,1,"Big");
				LCD_ShowString(1,1,"Again:");
				Answer=0;
				LCD_ShowString(1,7,"Right ");
				LCD_ShowNum(1,7,Answer,3);
		
			}

			
		}	
	}

	
}




